import {
  ClientFormData,
  ClientPageResult,
  ClientQueryParam,
} from '@/types/api/system/client';
import request from '@/utils/request';
import { AxiosPromise } from 'axios';
// @ts-ignore
import {AUTH_PATH_WEB_PREFIX} from '@/types/store/prefix.d.ts';

export function listClientPages(
  queryParams: ClientQueryParam
): AxiosPromise<ClientPageResult> {
  return request({
    url: AUTH_PATH_WEB_PREFIX + '/client/page',
    method: 'get',
    params: queryParams,
  });
}

export function getClientFormDetial(id: number): AxiosPromise<ClientFormData> {
  return request({
    url: AUTH_PATH_WEB_PREFIX + '/client/' + id + "/info",
    method: 'get',
  });
}

export function addClient(data: ClientFormData) {
  return request({
    url: AUTH_PATH_WEB_PREFIX + '/client',
    method: 'post',
    data: data,
  });
}

export function updateClient(id: string, data: ClientFormData) {
  return request({
    url: AUTH_PATH_WEB_PREFIX + '/client/' + id,
    method: 'put',
    data: data,
  });
}

export function deleteClients(ids: string) {
  return request({
    url: AUTH_PATH_WEB_PREFIX + '/client/list',
    method: 'delete',
    params: {ids: ids},
  });
}
